﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimaryAlgorithm.FirstUniqChar
{
    class MainProject
    {
        static void Main(string[] args)
        {
            string s = "leetcodel";
            Console.WriteLine(FirstUniqChar(s));
            Console.ReadKey();
        }
        public static int FirstUniqChar(string s)
        {
            if (s.Length==0)
            {
                return -1;
            }
            int last = 0;
            int next = 0;
            while (last!=s.Length)
            {
                if (next == s.Length)
                {
                    return last;
                }
                if (last!=next &&s[last] == s[next])
                {
                    last += 1;
                    next = 0;
                    continue;
                }
                next++;
            }
            return -1;
        }
    }

}
